package www.bw.com.exceptionhandlers;

import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(UnauthorizedException.class)
    public void handlerUnauthorizedException(HttpServletRequest request, HttpServletResponse response){
        try {
            response.sendRedirect(request.getContextPath()+"/403.html");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
